<?php
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: Role.php 5336 2010-09-07 08:15:47Z huuphuoc $
 * @since		2.0.5
 */

class Bizprofile_Models_Dao_Pdo_Mysql_Currency extends Tomato_Model_Dao
	implements Bizprofile_Models_Interface_Currency
{
	public function convert($entity)
	{
		return new Bizprofile_Models_Currency($entity); 
	}
	
	public function getCurrencies()
	{
		$rs = $this->_conn
					->select()
            		->from(array('r' => $this->_prefix . 'currency'))
            		->order('currency_id DESC')
					->query()
					->fetchAll();
		return new Tomato_Model_RecordSet($rs, $this);
	}
	
	public function getById($id) 
	{
		$row = $this->_conn
					->select()
					->from(array('r' => $this->_prefix . 'currency'))
					->where('r.currency_id = ?', $id)
					->limit(1)
					->query()
					->fetch();
		return (null == $row) ? null : new Bizprofile_Models_Currency($row);
	}
}
